<%@include file="/WEB-INF/includes/taglibs.jsp"%>
<c:set var="runningTotal" scope="request" value="0"/>
<table class="content">		
	<tr>
		<td>
			<table class="balance">
				<tr>
					<th>Account name</th>        
                    <th>Created</th> 
                    <th>Last updated</th>          
                    <th>Balance</th>					
				</tr>
                <c:if test="${empty accounts}">
                	<tr>
                		<td colspan="4">There are no accounts yet. Click 'Add Account' above to add some.</td>
                	</tr>
                </c:if>                
                <c:forEach items="${accounts}" var="account">
                	<c:set var="runningTotal" scope="request" value="${runningTotal + account.balance}"/>
                    <tr>
                        <td>
                        	<spring:url value="/accounts/${account.id}" var="urlAccount"/>
                        	<a href="${urlAccount}"><c:out value="${account.name}"/></a>
                        </td>
                        <td></td> 
                        <td></td>                                   
                        <td class="balance">                        	                            
                            <fmt:formatNumber value="${account.balance}" type="currency" currencySymbol="$" />                            
                        </td>        
                    </tr>
                </c:forEach>
                <tr class="total">
                	<td colspan="3">Total accounts balance</td>
                	<td class="balance"><fmt:formatNumber value="${runningTotal}" type="currency" currencySymbol="$" /></td>             
                </tr>
			</table>
		</td>
	</tr>
</table>